package 常用api;

public class 守护线程 {
    public static void main(String[] args) {
        Thread t =new Thread(new Runnable() {
            @Override
            public void run() {
                while(true){
                    try {
                        Thread.sleep(1000);
                        System.out.println("正在运行");
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        //t线程作为守护线程，整个java进程，就没有处于活跃的非守护线程了
        t.setDaemon(true);
        t.start();
        System.out.println("主线程即将退出");
    }
}
